<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 编写函数实现获取所有实参并对所有实参求平均值和最大值。
        function avgAndMax(arr) {
            if (!Array.isArray(arr) || arr.length === 0) {
                return { avg: null, max: null };
            }
            const sum = arr.reduce((acc, val) => acc + val, 0);
            return {
                avg: sum / arr.length,
                max: Math.max(...arr)
            };
        }
        console.log(avgAndMax([1, 2, 3]));
    </script>
</body>
</html>